<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QDesktopWidget Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QDesktopWidget Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QDesktopWidget class provides access to screen information
on multi-head systems. <a href="#details">More...</a></p>

<p>Inherits <a href="qwidget.html">QWidget</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qdesktopwidget.html#QDesktopWidget">__init__</a></b> (<i>self</i>)</li><li><div class="fn" />QRect <b><a href="qdesktopwidget.html#availableGeometry">availableGeometry</a></b> (<i>self</i>, int&#160;<i>screen</i>&#160;=&#160;-1)</li><li><div class="fn" />QRect <b><a href="qdesktopwidget.html#availableGeometry-2">availableGeometry</a></b> (<i>self</i>, QWidget&#160;<i>widget</i>)</li><li><div class="fn" />QRect <b><a href="qdesktopwidget.html#availableGeometry-3">availableGeometry</a></b> (<i>self</i>, QPoint&#160;<i>point</i>)</li><li><div class="fn" />bool <b><a href="qdesktopwidget.html#isVirtualDesktop">isVirtualDesktop</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qdesktopwidget.html#numScreens">numScreens</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qdesktopwidget.html#primaryScreen">primaryScreen</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qdesktopwidget.html#resizeEvent">resizeEvent</a></b> (<i>self</i>, QResizeEvent&#160;<i>e</i>)</li><li><div class="fn" />QWidget <b><a href="qdesktopwidget.html#screen">screen</a></b> (<i>self</i>, int&#160;<i>screen</i>&#160;=&#160;-1)</li><li><div class="fn" />int <b><a href="qdesktopwidget.html#screenCount">screenCount</a></b> (<i>self</i>)</li><li><div class="fn" />QRect <b><a href="qdesktopwidget.html#screenGeometry">screenGeometry</a></b> (<i>self</i>, int&#160;<i>screen</i>&#160;=&#160;-1)</li><li><div class="fn" />QRect <b><a href="qdesktopwidget.html#screenGeometry-2">screenGeometry</a></b> (<i>self</i>, QWidget&#160;<i>widget</i>)</li><li><div class="fn" />QRect <b><a href="qdesktopwidget.html#screenGeometry-3">screenGeometry</a></b> (<i>self</i>, QPoint&#160;<i>point</i>)</li><li><div class="fn" />int <b><a href="qdesktopwidget.html#screenNumber">screenNumber</a></b> (<i>self</i>, QWidget&#160;<i>widget</i>&#160;=&#160;None)</li><li><div class="fn" />int <b><a href="qdesktopwidget.html#screenNumber-2">screenNumber</a></b> (<i>self</i>, QPoint)</li></ul><h3>Qt Signals</h3><ul><li><div class="fn" />void <b><a href="qdesktopwidget.html#resized">resized</a></b> (int)</li><li><div class="fn" />void <b><a href="qdesktopwidget.html#screenCountChanged">screenCountChanged</a></b> (int)</li><li><div class="fn" />void <b><a href="qdesktopwidget.html#workAreaResized">workAreaResized</a></b> (int)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QDesktopWidget class provides access to screen information
on multi-head systems.</p>
<p>Systems with more than one graphics card and monitor can manage
the physical screen space available either as multiple desktops, or
as a large virtual desktop.</p>
<p>This class provides information about the user's desktop, such
as its total size, number of screens, the geometry of each screen,
and whether they are configured as separate desktops or a single
virtual desktop.</p>
<p>Widgets provided by Qt use this class to place tooltips, menus
and dialog boxes on the correct screen for their parent or
application widgets. Applications can use this class to obtain
information that can be used to save window positions, or to place
child widgets and dialogs on one particular screen.</p>
<a id="obtaining-a-desktop-widget" name="obtaining-a-desktop-widget" />
<h3>Obtaining a Desktop Widget</h3>
<p>The <a href="qapplication.html#desktop">QApplication.desktop</a>() function is
used to get an instance of QDesktopWidget.</p>
<p>The widget's <a href="qdesktopwidget.html#screenGeometry">screenGeometry</a>() function
provides information about the geometry of the available screens
with. The number of screens available is returned by <a href="qdesktopwidget.html#screenCount-prop">screenCount</a>, and the
<a href="qdesktopwidget.html#screenCountChanged">screenCountChanged</a>()
signal is emitted when screens are added or removed. The screen
number that a particular point or widget is located in is returned
by <a href="qdesktopwidget.html#screenNumber">screenNumber</a>().</p>
<a id="screen-geometry" name="screen-geometry" />
<h3>Screen Geometry</h3>
<p>To obtain the dimensions of a particular screen, call the
<a href="qdesktopwidget.html#screenGeometry">screenGeometry</a>()
function. On some desktop environments, not all of the screen is
available for applications to use; for example, an application dock
or menu bar may take up some space. Use the <a href="qdesktopwidget.html#availableGeometry">availableGeometry</a>()
function to obtain the available area for applications.</p>
<p>QDesktopWidget also inherits the <a href="qwidget.html">QWidget</a> properties, <a href="qwidget.html#width-prop">width</a>() and <a href="qwidget.html#height-prop">height</a>(), which specify the size of
the desktop. However, for desktops with multiple screens, the size
of the desktop is the union of all the screen sizes, so <a href="qwidget.html#width-prop">width</a>() and <a href="qwidget.html#height-prop">height</a>() should <i>not</i> be used
for computing the size of a widget to be placed on one of the
screens.</p>
<p>On systems that are configured to use the available screens as a
single, large virtual desktop, the <a href="qdesktopwidget.html#virtualDesktop-prop">virtualDesktop</a>
property will be set to true. In this case, the widget's size is
usually the size of the bounding rectangle of all the screens.</p>
<a id="use-of-the-primary-screen" name="use-of-the-primary-screen" />
<h3>Use of the Primary Screen</h3>
<p>For an application, the screen where the main widget resides is
the primary screen. This is stored in the <a href="qdesktopwidget.html#primaryScreen-prop">primaryScreen</a>
property. All windows opened in the context of the application
should be constrained to the boundaries of the primary screen; for
example, it would be inconvenient if a dialog box popped up on a
different screen, or split over two screens.</p>
<p class="centerAlign"><img alt="Managing Multiple Screens" src="images/qdesktopwidget.png" /></p>
<p>In the illustration above, Application One's primary screen is
screen 0, and App Two's primary screen is screen 1.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QDesktopWidget" />QDesktopWidget.__init__ (<i>self</i>)</h3><h3 class="fn"><a name="availableGeometry" /><a href="qrect.html">QRect</a> QDesktopWidget.availableGeometry (<i>self</i>, int&#160;<i>screen</i>&#160;=&#160;-1)</h3><p>Returns the available geometry of the screen with index
<i>screen</i>. What is available will be subrect of <a href="qdesktopwidget.html#screenGeometry">screenGeometry</a>() based on
what the platform decides is available (for example excludes the
dock and menu bar on Mac OS X, or the task bar on Windows). The
default screen is used if <i>screen</i> is -1.</p>
<p><b>Note:</b> In Symbian devices the available geometry reported
by <a href="qdesktopwidget.html">QDesktopWidget</a> is not
guaranteed to be correct at the time the geometry change resize
event is passed to widgets. The correct way to listen for available
geometry changes is to connect to the <a href="qdesktopwidget.html#workAreaResized">workAreaResized</a>() signal
of <a href="qdesktopwidget.html">QDesktopWidget</a>.</p>
<p><b>See also</b> <a href="qdesktopwidget.html#screenNumber">screenNumber</a>() and <a href="qdesktopwidget.html#screenGeometry">screenGeometry</a>().</p>


<h3 class="fn"><a name="availableGeometry-2" /><a href="qrect.html">QRect</a> QDesktopWidget.availableGeometry (<i>self</i>, <a href="qwidget.html">QWidget</a>&#160;<i>widget</i>)</h3><p>This is an overloaded function.</p>
<p>Returns the available geometry of the screen which contains
<i>widget</i>.</p>
<p><b>See also</b> <a href="qdesktopwidget.html#screenGeometry">screenGeometry</a>().</p>


<h3 class="fn"><a name="availableGeometry-3" /><a href="qrect.html">QRect</a> QDesktopWidget.availableGeometry (<i>self</i>, <a href="qpoint.html">QPoint</a>&#160;<i>point</i>)</h3><p>This is an overloaded function.</p>
<p>Returns the available geometry of the screen which contains
<i>p</i>.</p>
<p><b>See also</b> <a href="qdesktopwidget.html#screenGeometry">screenGeometry</a>().</p>


<h3 class="fn"><a name="isVirtualDesktop" />bool QDesktopWidget.isVirtualDesktop (<i>self</i>)</h3><h3 class="fn"><a name="numScreens" />int QDesktopWidget.numScreens (<i>self</i>)</h3><h3 class="fn"><a name="primaryScreen" />int QDesktopWidget.primaryScreen (<i>self</i>)</h3><h3 class="fn"><a name="resizeEvent" />QDesktopWidget.resizeEvent (<i>self</i>, <a href="qresizeevent.html">QResizeEvent</a>&#160;<i>e</i>)</h3><p>Reimplemented from <a href="qwidget.html#resizeEvent">QWidget.resizeEvent</a>().</p>


<h3 class="fn"><a name="screen" /><a href="qwidget.html">QWidget</a> QDesktopWidget.screen (<i>self</i>, int&#160;<i>screen</i>&#160;=&#160;-1)</h3><p>Returns a widget that represents the screen with index
<i>screen</i> (a value of -1 means the default screen).</p>
<p>If the system uses a virtual desktop, the returned widget will
have the geometry of the entire virtual desktop; i.e., bounding
every <i>screen</i>.</p>
<p><b>See also</b> <a href="qdesktopwidget.html#primaryScreen-prop">primaryScreen</a>,
<a href="qdesktopwidget.html#screenCount-prop">screenCount</a>, and
<a href="qdesktopwidget.html#virtualDesktop-prop">virtualDesktop</a>.</p>


<h3 class="fn"><a name="screenCount" />int QDesktopWidget.screenCount (<i>self</i>)</h3><h3 class="fn"><a name="screenGeometry" /><a href="qrect.html">QRect</a> QDesktopWidget.screenGeometry (<i>self</i>, int&#160;<i>screen</i>&#160;=&#160;-1)</h3><p>Returns the geometry of the screen with index <i>screen</i>. The
default screen is used if <i>screen</i> is -1.</p>
<p><b>Note:</b> In Symbian devices the screen geometry reported by
<a href="qdesktopwidget.html">QDesktopWidget</a> is not guaranteed
to be correct at the time the geometry change resize event is
passed to widgets. The correct way to listen for screen geometry
changes is to connect to the <a href="qdesktopwidget.html#resized">resized</a>() signal of <a href="qdesktopwidget.html">QDesktopWidget</a>.</p>
<p><b>See also</b> <a href="qdesktopwidget.html#screenNumber">screenNumber</a>().</p>


<h3 class="fn"><a name="screenGeometry-2" /><a href="qrect.html">QRect</a> QDesktopWidget.screenGeometry (<i>self</i>, <a href="qwidget.html">QWidget</a>&#160;<i>widget</i>)</h3><p>This is an overloaded function.</p>
<p>Returns the geometry of the screen which contains
<i>widget</i>.</p>


<h3 class="fn"><a name="screenGeometry-3" /><a href="qrect.html">QRect</a> QDesktopWidget.screenGeometry (<i>self</i>, <a href="qpoint.html">QPoint</a>&#160;<i>point</i>)</h3><p>This is an overloaded function.</p>
<p>Returns the geometry of the screen which contains <i>p</i>.</p>


<h3 class="fn"><a name="screenNumber" />int QDesktopWidget.screenNumber (<i>self</i>, <a href="qwidget.html">QWidget</a>&#160;<i>widget</i>&#160;=&#160;None)</h3><p>Returns the index of the screen that contains the largest part
of <i>widget</i>, or -1 if the widget not on a screen.</p>
<p><b>See also</b> <a href="qdesktopwidget.html#primaryScreen-prop">primaryScreen</a>.</p>


<h3 class="fn"><a name="screenNumber-2" />int QDesktopWidget.screenNumber (<i>self</i>, <a href="qpoint.html">QPoint</a>)</h3><p>This is an overloaded function.</p>
<p>Returns the index of the screen that contains the <i>point</i>,
or the screen which is the shortest distance from the
<i>point</i>.</p>
<p><b>See also</b> <a href="qdesktopwidget.html#primaryScreen-prop">primaryScreen</a>.</p>


<hr /><h2>Qt Signal Documentation</h2><h3 class="fn"><a name="resized" />void resized (int)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted when the size of <i>screen</i>
changes.</p>


<h3 class="fn"><a name="screenCountChanged" />void screenCountChanged (int)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted when the number of screens changes to
<i>newCount</i>.</p>
<p>This function was introduced in Qt 4.6.</p>
<p><b>See also</b> <a href="qdesktopwidget.html#screenCount-prop">screenCount</a>.</p>


<h3 class="fn"><a name="workAreaResized" />void workAreaResized (int)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted when the work area available on
<i>screen</i> changes.</p>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;4.9.1 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2011</td><td align="right" width="25%">Qt&#160;4.8.0</td></tr></table></div></address></body></html>